package com.roc.service.impl;

import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.roc.bean.ErrorCountBean;
import com.roc.dao.DaoException;
import com.roc.dao.IBaseDao;
import com.roc.dao.ISQLBaseDao;
import com.roc.newPage.IPageDao;
import com.roc.pojo.Operators;
import com.roc.pojo.RiskSurveyOrder;
import com.roc.service.EstrnStasticsService;
import com.roc.service.RegisterOrderProcessService;
import com.roc.service.ServiceException;
import com.roc.util.Constance;
import com.roc.util.DateUtil;
import com.roc.util.OrderType;
import com.roc.util.constant.ConfigProperties;
import com.roc.util.constant.Constant;
import com.roc.util.constant.SysLogType;
import com.roc.web.action.windcontroll.OrderProcessSearchCondition;
/**
 * 差错管理
 * @author 160711BB
 *
 */
@Service
public class RegisterOrderProcessServiceImpl implements RegisterOrderProcessService{
	
	private Logger logger = LogManager.getLogger(RegisterOrderProcessServiceImpl.class);
	
	@Autowired
	private IBaseDao baseDao;
	
	@Autowired
	private ISQLBaseDao sqlBaseDao;
	
	@Autowired
	private  EstrnStasticsService estrnStasticsService;
	@Autowired
     private IPageDao pageDao;
	
	

	/**
	 * 登记
	 */
	@Transactional(rollbackFor = { ServiceException.class })
	@Override
	public Map<String,Object> registerOrderPro(RiskSurveyOrder rso,Operators op) throws ServiceException {
		Map<String,Object> resMap = new HashMap<String, Object>();
		try {
			
			if("".equals(Constance.Null2EmptyTrim(rso.getMerchantNo()))){
				resMap.put("msg", "商户号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getAccountNo()))){
				resMap.put("msg", "交易账号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getSystemNo()))){
				resMap.put("msg", "系统参考号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getTransAmt()))){
				resMap.put("msg", "交易金额为空");
				return resMap;
			}
			
			
			if("".equals(Constance.Null2EmptyTrim(rso.getTransDate()))){
				resMap.put("msg", "清算/交易 日期");
				return resMap;
			}
			
			logger.info(op.getAccountNo()+"保存商户【"+rso.getMerchantNo()+"】差错管理信息开始");
			
			String today = DateUtil.getDate(new Date(), 0, "yyyyMMdd");
			if(!"".equals(Constance.Null2EmptyTrim(rso.getFirstQuery()))){
				rso.setFirstQueryDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getSecondQuery()))){
				rso.setSecondQueryDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getFirstSurvey()))){
				rso.setFirstSurveyDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getSecondSurvey()))){
				rso.setSecondSurveyDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getLoanAdjust()))){
				rso.setLoanAdjustDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getFirstWithdrawCash()))){
				rso.setFirstWithDrawCashDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getFirstChargeBack()))){
				rso.setFirstChargeBackDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getSecondWithDrawCash()))){
				rso.setSecondWithDrawCashDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getSecondChargeBack()))){
				rso.setSecondChargeBackDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getExceptionNegotiate()))){
				rso.setExceptionNegotiateDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getExceptionLongMoney()))){
				rso.setExceptionLongMoneyDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getCollectionWithDrawCash()))){
				rso.setCollectionWithDrawCashDate(today);
			}
			
			if(!"".equals(Constance.Null2EmptyTrim(rso.getCollectionNegotiate()))){
				rso.setCollectionNegotiateDate(today);
			}
			
			rso.setOper(op.getAccountNo());
			
			baseDao.editSave(rso);
			
			baseDao.addSyslog(SysLogType.INSERT_ORDER_PROCESS.getCode(),
					SysLogType.INSERT_ORDER_PROCESS.getName(),
					op.getAccountNo(), 
					"操作员【" + op.getAccountNo()+ "】，添加商户【"+rso.getMerchantNo()+"】的差错管理信息成功");
			
			logger.info(op.getAccountNo()+"保存商户【"+rso.getMerchantNo()+"】差错管理信息成功");
		} catch (Exception e) {
			logger.error("差错管理登记异常："+e);
			throw new ServiceException("差错管理登记异常："+e);
		}
		
		resMap.put("msg", "操作成功");
		return resMap;
	}

	@Transactional(readOnly=true)
	@Override
	public RiskSurveyOrder obtainRiskOrderDetail(String riskId)
			throws ServiceException {
		String hql = "FROM RiskSurveyOrder T WHERE T.id=?";
		RiskSurveyOrder rso = new RiskSurveyOrder(); 
		try {
			rso = (RiskSurveyOrder) baseDao.createQueryUniqueResult(hql, new Object[]{Long.parseLong(riskId)});
		} catch (DaoException e) {
			logger.error("查询差错管理详情异常："+e);
		}
		return rso;
	}

	@Transactional(rollbackFor = { ServiceException.class })
	@Override
	public synchronized Map<String,Object> modifyRiskOrder(RiskSurveyOrder rso,Operators op) throws ServiceException {
		Map<String,Object> resMap = new HashMap<String, Object>();
		String hql = "FROM RiskSurveyOrder T WHERE T.id=?";
		RiskSurveyOrder selRso = new RiskSurveyOrder();
		try {
			
			if("".equals(Constance.Null2EmptyTrim(rso.getMerchantNo()))){
				resMap.put("msg", "商户号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getAccountNo()))){
				resMap.put("msg", "交易账号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getSystemNo()))){
				resMap.put("msg", "系统参考号为空");
				return resMap;
			}
			
			if("".equals(Constance.Null2EmptyTrim(rso.getTransAmt()))){
				resMap.put("msg", "交易金额为空");
				return resMap;
			}
			
			
			if("".equals(Constance.Null2EmptyTrim(rso.getTransDate()))){
				resMap.put("msg", "清算/交易 日期");
				return resMap;
			}
			
			logger.info(op.getAccountNo()+"修改商户【"+rso.getMerchantNo()+"】差错管理信息开始");
			
			selRso = (RiskSurveyOrder) baseDao.createQueryUniqueResult(hql, new Object[]{rso.getId()});
			
			String today = DateUtil.getDate(new Date(), 0, "yyyyMMdd");
			
			if(!Constance.Null2EmptyTrim(rso.getFirstQuery()).equals(Constance.Null2EmptyTrim(selRso.getFirstQuery())) && !"".equals(Constance.Null2EmptyTrim(rso.getFirstQuery()))){
				selRso.setFirstQueryDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getFirstQuery()))){
				selRso.setFirstQueryDate("");
			}
			selRso.setFirstQuery(Constance.Null2EmptyTrim(rso.getFirstQuery()));
			
			if(!Constance.Null2EmptyTrim(rso.getSecondQuery()).equals(Constance.Null2EmptyTrim(selRso.getSecondQuery())) && !"".equals(Constance.Null2EmptyTrim(rso.getSecondQuery()))){
				selRso.setSecondQueryDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getSecondQuery()))){
				selRso.setSecondQueryDate("");
			}
			selRso.setSecondQuery(Constance.Null2EmptyTrim(rso.getSecondQuery()));
			
			if(!Constance.Null2EmptyTrim(rso.getFirstSurvey()).equals(Constance.Null2EmptyTrim(selRso.getFirstSurvey())) && !"".equals(Constance.Null2EmptyTrim(rso.getFirstSurvey()))){
				selRso.setFirstSurveyDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getFirstSurvey()))){
				selRso.setFirstSurveyDate("");
			}
			selRso.setFirstSurvey(Constance.Null2EmptyTrim(rso.getFirstSurvey()));
			
			if(!Constance.Null2EmptyTrim(rso.getSecondSurvey()).equals(Constance.Null2EmptyTrim(selRso.getSecondSurvey())) && !"".equals(Constance.Null2EmptyTrim(rso.getSecondSurvey()))){
				selRso.setSecondSurveyDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getSecondSurvey()))){
				selRso.setSecondSurveyDate("");
			}
			selRso.setSecondSurvey(Constance.Null2EmptyTrim(rso.getSecondSurvey()));
			
			if(!Constance.Null2EmptyTrim(rso.getLoanAdjust()).equals(Constance.Null2EmptyTrim(selRso.getLoanAdjust())) && !"".equals(Constance.Null2EmptyTrim(rso.getLoanAdjust()))){
				selRso.setLoanAdjustDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getLoanAdjust()))){
				selRso.setLoanAdjustDate("");
			}
			selRso.setLoanAdjust(Constance.Null2EmptyTrim(rso.getLoanAdjust()));
			
			if(!Constance.Null2EmptyTrim(rso.getFirstWithdrawCash()).equals(Constance.Null2EmptyTrim(selRso.getFirstWithdrawCash())) && !"".equals(Constance.Null2EmptyTrim(rso.getFirstWithdrawCash()))){
				selRso.setFirstWithDrawCashDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getFirstWithdrawCash()))){
				selRso.setFirstWithDrawCashDate("");
			}
			selRso.setFirstWithdrawCash(Constance.Null2EmptyTrim(rso.getFirstWithdrawCash()));
			
			if(!Constance.Null2EmptyTrim(rso.getFirstChargeBack()).equals(Constance.Null2EmptyTrim(selRso.getFirstChargeBack())) && !"".equals(Constance.Null2EmptyTrim(rso.getFirstChargeBack()))){
				selRso.setFirstChargeBackDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getFirstChargeBack()))){
				selRso.setFirstChargeBackDate("");
			}
			selRso.setFirstChargeBack(Constance.Null2EmptyTrim(rso.getFirstChargeBack()));
			
			if(!Constance.Null2EmptyTrim(rso.getSecondWithDrawCash()).equals(Constance.Null2EmptyTrim(selRso.getSecondWithDrawCash())) && !"".equals(Constance.Null2EmptyTrim(rso.getSecondWithDrawCash()))){
				selRso.setSecondWithDrawCashDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getSecondWithDrawCash()))){
				selRso.setSecondWithDrawCashDate("");
			}
			selRso.setSecondWithDrawCash(Constance.Null2EmptyTrim(rso.getSecondWithDrawCash()));
			
			if(!Constance.Null2EmptyTrim(rso.getSecondChargeBack()).equals(Constance.Null2EmptyTrim(selRso.getSecondChargeBack())) && !"".equals(Constance.Null2EmptyTrim(rso.getSecondChargeBack()))){
				selRso.setSecondChargeBackDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getSecondChargeBack()))){
				selRso.setSecondChargeBackDate("");
			}
			selRso.setSecondChargeBack(Constance.Null2EmptyTrim(rso.getSecondChargeBack()));
			
			if(!Constance.Null2EmptyTrim(rso.getExceptionNegotiate()).equals(Constance.Null2EmptyTrim(selRso.getExceptionNegotiate())) && !"".equals(Constance.Null2EmptyTrim(rso.getExceptionNegotiate()))){
				selRso.setExceptionNegotiateDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getExceptionNegotiate()))){
				selRso.setExceptionNegotiateDate("");
			}
			selRso.setExceptionNegotiate(Constance.Null2EmptyTrim(rso.getExceptionNegotiate()));
			
			if(!Constance.Null2EmptyTrim(rso.getExceptionLongMoney()).equals(Constance.Null2EmptyTrim(selRso.getExceptionLongMoney())) && !"".equals(Constance.Null2EmptyTrim(rso.getExceptionLongMoney()))){
				selRso.setExceptionLongMoneyDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getExceptionLongMoney()))){
				selRso.setExceptionLongMoneyDate("");
			}
			selRso.setExceptionLongMoney(Constance.Null2EmptyTrim(rso.getExceptionLongMoney()));
			
			if(!Constance.Null2EmptyTrim(rso.getCollectionWithDrawCash()).equals(Constance.Null2EmptyTrim(selRso.getCollectionWithDrawCash())) && !"".equals(Constance.Null2EmptyTrim(rso.getCollectionWithDrawCash()))){
				selRso.setCollectionWithDrawCashDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getCollectionWithDrawCash()))){
				selRso.setCollectionWithDrawCashDate("");
			}
			selRso.setCollectionWithDrawCash(Constance.Null2EmptyTrim(rso.getCollectionWithDrawCash()));
			
			if(!Constance.Null2EmptyTrim(rso.getCollectionNegotiate()).equals(Constance.Null2EmptyTrim(selRso.getCollectionNegotiate())) && !"".equals(Constance.Null2EmptyTrim(rso.getCollectionNegotiate()))){
				selRso.setCollectionNegotiateDate(today);
			}else if("".equals(Constance.Null2EmptyTrim(rso.getCollectionNegotiate()))){
				selRso.setCollectionNegotiateDate("");
			}
			selRso.setCollectionNegotiate(Constance.Null2EmptyTrim(rso.getCollectionNegotiate()));
			
			selRso.setOper(op.getAccountNo());
			
			baseDao.editUpdate(selRso);
			
			baseDao.addSyslog(SysLogType.UPDATE_ORDER_PROCESS.getCode(),
					SysLogType.UPDATE_ORDER_PROCESS.getName(),
					op.getAccountNo(), 
					"操作员【" + op.getAccountNo()+ "】，修改商户【"+rso.getId()+"】的差错管理信息成功");
		} catch (Exception e) {
			logger.error("修改差错管理异常："+e);
			throw new ServiceException("修改差错管理异常："+e);
		}
		resMap.put("msg", "操作成功");
		return resMap;
		
	}

	@Transactional(rollbackFor = { ServiceException.class })
	@Override
	public synchronized Map<String, Object> deleteRiskOrder(String riskId, Operators op)
			throws ServiceException {
		Map<String,Object> resMap = new HashMap<String, Object>();
		String sql = "delete from T_RISK_SURVEY_ORDER t where t.id=?";
		List<Object> paramsList = new ArrayList<Object>();
		try {
			paramsList.add(riskId);
			int deleteCount = sqlBaseDao.deleteBySql(sql, paramsList);
			if(deleteCount != 1){
				throw new ServiceException("删除差错管理数据异常");
			}
			
			baseDao.addSyslog(SysLogType.DELETE_ORDER_PROCESS.getCode(),
					SysLogType.DELETE_ORDER_PROCESS.getName(),
					op.getAccountNo(), 
					"操作员【" + op.getAccountNo()+ "】，删除商户【"+riskId+"】的差错管理信息成功");
		} catch (Exception e) {
			logger.error("删除差错管理数据异常："+e);
			throw new ServiceException("删除差错管理数据异常："+e);
		}
		resMap.put("msg", "操作成功");
		return resMap;
	}
	
	/**
	 * 将Excel中的数据转存入List对象中
	 * 
	 * @param upload
	 *            上传的文件
	 * @param trList
	 *            存储Excel中数据的List对象
	 * @return
	 */
	public boolean excelToList(File upload,Map<String ,Object> resultMap, List<List<Object>> trList,String imporNum) {

		try {
			// 构造 XSSFWorkbook 对象，strPath 传入文件路径
			XSSFWorkbook xwb = new XSSFWorkbook(upload.getPath());
			// 得到Excel工作表对象
			XSSFSheet sheet = xwb.getSheetAt(0);
			// 得到行数
			int trLength = sheet.getPhysicalNumberOfRows();
			logger.info("Excel中记录的总行数是：" + (trLength - 1));
			
			// 每条记录列数
			Row row = sheet.getRow(0);
			int tdLength = row.getPhysicalNumberOfCells();
			logger.info("每条记录的列数："+tdLength);
			Row modelTitle = sheet.getRow(0);
			String[] modelTitleArray = {"调单类别","清算日期","系统跟踪号","（转出）主账号","原交易金额","原因码","商户代码"};
			boolean modelTitleFlag = false;
			for(int i =0;i<modelTitleArray.length;i++){
				Cell modelTitleCell  = modelTitle.getCell(i);
				modelTitleCell.setCellType(Cell.CELL_TYPE_STRING);
				if(!modelTitleArray[i].equals(modelTitleCell.getStringCellValue())){
					modelTitleFlag = true;
					break;
				}
			}
			if(modelTitleFlag){
				resultMap.put("msg", "Excel列名错误");
				return false;
			}
			
			int imMerNum = Integer.parseInt(imporNum);
			if(imMerNum != (trLength - 1)){
				resultMap.put("msg", "导入总数填写错误");
				return false;
			}
			for (int i = 1; i < trLength; i++) {
				List<Object> tdList = new ArrayList<Object>();
				Row r = sheet.getRow(i);
				
				for (int j = 0; j < tdLength; j++) {
					Cell c = r.getCell(j);
					/*
					 * 将所有列的内容都设置成String类型，否则会出Excel异常： Cannot get a text value
					 * from a numeric cell
					 */
					if (c != null) {
						c.setCellType(Cell.CELL_TYPE_STRING);
						tdList.add(c.getStringCellValue());
					}else{
						tdList.add("");
					}
					
				}

				trList.add(tdList);
			}
			
		} catch (Exception e) {
			resultMap.put("msg", "Excel解析异常,请检查是否存在空白行");
			logger.error("将Excel中数据封装到List容器中异常：" + e.getMessage());
//			e.printStackTrace();
			return false;
		}
		return true;
	}

	@Transactional(rollbackFor={ServiceException.class})
	@Override
 
	

	public synchronized Map<String, Object> batchImportOrder(File upload, Operators oper,String imporNum) throws ServiceException {
		String selSql = "FROM RiskSurveyOrder T WHERE T.transDate=? and T.systemNo=? and T.accountNo=? and T.transAmt=? and T.merchantNo=?"; 
		Map<String,Object> resultMap = new HashMap<String, Object>();
		List<List<Object>> trList = new ArrayList<List<Object>>();// 将Excel中数据存入List中
		Map<String,String> reasonCdMap = ConfigProperties.getSysDB1("RISK_CONTROL_D",false);
		int count = 0;//统计变更条数
		try {
			boolean importToListFlag = excelToList(upload, resultMap, trList, imporNum);
			if(!importToListFlag){
				return resultMap;
			}
			
			logger.info(oper.getAccountNo()+"开始批量导入差错管理数据");
			String today = DateUtil.getDate(new Date(), 0, "yyyyMMdd");
			
			
			//校验数据是否合规
			if(trList != null && trList.size()>0){
				for(int i=0;i<trList.size();i++){
					List<Object> tdList = trList.get(i);
					boolean changeFlag = true;//是否做过变更
					
					//非空
					for(int j=0;j<tdList.size();j++){
						String td = Constance.Null2EmptyTrim(tdList.get(j));
						if("".equals(td)){
							resultMap.put("msg", "第"+(i+1)+"行存在空值");
							return resultMap;
						}
					}
					
					//调单类别
					String riskType = Constance.Null2EmptyTrim(tdList.get(0));
					if(Constant.REASON_MAP.get(riskType) == null){
						resultMap.put("msg", "第"+(i+1)+"行调单类别填写错误");
						return resultMap;
					}
					
					//清算日期
					String date = Constance.Null2EmptyTrim(tdList.get(1));
					if(!isRegularTime(date)){
						resultMap.put("msg", "第"+(i+1)+"行清算日期填写错误");
						return resultMap;
					}
					
					//系统跟踪号
					String systemNo = Constance.Null2EmptyTrim(tdList.get(2));
					
					//主账号
					String priAccoutnNO = Constance.Null2EmptyTrim(tdList.get(3));
					
					//交易金额
					String amt = Constance.Null2EmptyTrim(tdList.get(4));
					if(!isPositiveInteger(amt)){
						resultMap.put("msg", "第"+(i+1)+"行原交易金额填写错误");
						return resultMap;
					}
					
					//原因码
					String reasonCd = Constance.Null2EmptyTrim(tdList.get(5));
					if(reasonCdMap.get(reasonCd)==null){
						resultMap.put("msg", "第"+(i+1)+"行原因码填写错误");
						return resultMap;
					}
					
					//商户号
					String mchtCd = Constance.Null2EmptyTrim(tdList.get(6));
					
					//除原因码和调单类别以外的五个字段可以唯一确定一笔记录
					RiskSurveyOrder rso = (RiskSurveyOrder) baseDao.createQueryUniqueResult(selSql, new Object[]{date,systemNo,priAccoutnNO,amt,mchtCd});
					
					if(rso == null){
						rso= new RiskSurveyOrder();
					}
					
					rso.setTransDate(date);
					rso.setSystemNo(systemNo);
					rso.setAccountNo(priAccoutnNO);
					rso.setTransAmt(amt);
					rso.setMerchantNo(mchtCd);
					
					//查询
					if("1000".equals(riskType)){
						if(!reasonCd.equals(rso.getFirstQuery())){
							rso.setFirstQuery(reasonCd);
							rso.setFirstQueryDate(today);
							changeFlag = false;
						}
					}
					//二次查询
					if("1001".equals(riskType)){
						if(!reasonCd.equals(rso.getSecondQuery())){
							rso.setSecondQuery(reasonCd);
							rso.setSecondQueryDate(today);
							changeFlag = false;
						}
					}
					//调单
					if("1002".equals(riskType)){
						if(!reasonCd.equals(rso.getFirstSurvey())){
							rso.setFirstSurvey(reasonCd);
							rso.setFirstSurveyDate(today);
							changeFlag = false;
						}
					}
					//二次调单
					if("1003".equals(riskType)){
						if(!reasonCd.equals(rso.getSecondSurvey())){
							rso.setSecondSurvey(reasonCd);
							rso.setSecondSurveyDate(today);
							changeFlag = false;
						}
					}
					//贷记调整
					if("1004".equals(riskType)){
						if(!reasonCd.equals(rso.getLoanAdjust())){
							rso.setLoanAdjust(reasonCd);
							rso.setLoanAdjustDate(today);
							changeFlag = false;
						}
					}
					//请款
					if("1005".equals(riskType)){
						if(!reasonCd.equals(rso.getFirstWithdrawCash())){
							rso.setFirstWithdrawCash(reasonCd);
							rso.setFirstWithDrawCashDate(today);
							changeFlag = false;
						}
					}
					//退单
					if("1006".equals(riskType)){
						if(!reasonCd.equals(rso.getFirstChargeBack())){
							rso.setFirstChargeBack(reasonCd);
							rso.setFirstChargeBackDate(today);
							changeFlag = false;
						}
					}
					//再请款
					if("1007".equals(riskType)){
						if(!reasonCd.equals(rso.getSecondWithDrawCash())){
							rso.setSecondWithDrawCash(reasonCd);
							rso.setSecondWithDrawCashDate(today);
							changeFlag = false;
						}
					}
					//二次退单
					if("1008".equals(riskType)){
						if(!reasonCd.equals(rso.getSecondChargeBack())){
							rso.setSecondChargeBack(reasonCd);
							rso.setSecondChargeBackDate(today);
							changeFlag = false;
						}
					}
					//例外协商
					if("1009".equals(riskType)){
						if(!reasonCd.equals(rso.getExceptionNegotiate())){
							rso.setExceptionNegotiate(reasonCd);
							rso.setExceptionNegotiateDate(today);
							changeFlag = false;
						}
					}
					//例外长款
					if("1010".equals(riskType)){
						if(!reasonCd.equals(rso.getExceptionLongMoney())){
							rso.setExceptionLongMoney(reasonCd);
							rso.setExceptionLongMoneyDate(today);
							changeFlag = false;
						}
					}
					//托收请款
					if("1011".equals(riskType)){
						if(!reasonCd.equals(rso.getCollectionWithDrawCash())){
							rso.setCollectionWithDrawCash(reasonCd);
							rso.setCollectionWithDrawCashDate(today);
							changeFlag = false;
						}
					}
					//托收协商
					if("1012".equals(riskType)){
						if(!reasonCd.equals(rso.getCollectionNegotiate())){
							rso.setCollectionNegotiate(reasonCd);
							rso.setCollectionNegotiateDate(today);
							changeFlag = false;
						}
					}
					
					if(!changeFlag){
						rso.setOper(oper.getAccountNo());
						
						baseDao.edit(rso);
						
						baseDao.addSyslog(SysLogType.BATCH_ORDER_PROCESS.getCode(),
								SysLogType.BATCH_ORDER_PROCESS.getName(),
								oper.getAccountNo(), 
								"操作员【" + oper.getAccountNo()+ "】，添加商户【"+rso.getMerchantNo()+"】的差错管理信息成功");
						count ++;
					}
					
				}
			}
			
			
		} catch (Exception e) {
			logger.error("差错管理批导异常："+e);
			throw new ServiceException("差错管理批导异常");
		}
		logger.info(oper.getAccountNo()+"批量导入差错管理数据结束");
		resultMap.put("msg", "操作成功,变更或新增【"+count+"】条数据");
		return resultMap;
	}
	
	/**
	 * 判断时间是否符合格式
	 * @param dateStr
	 * @return
	 */
	public static boolean isRegularTime(String dateStr){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
		Date date = null;
		try {
			
			date = sdf.parse(dateStr);
		} catch (ParseException e) {
			return false;
		}
		String ds = sdf.format(date);
		return ds.equals(dateStr);
	}
	
	/**
	 * 正浮点数
	 * @param str
	 * @return
	 */
	public static boolean isPositiveInteger(String str){
		String regextStr = "^([1-9][\\d]*|0)(\\.[\\d]*)?$";
		 Pattern pattern = Pattern.compile(regextStr);  
	     Matcher isNum = pattern.matcher(str);  
		return isNum.matches();
	}
	


	@Override
	public int queryOrderCount(OrderProcessSearchCondition searchCondition)
			throws ServiceException {
	 StringBuffer sb = new StringBuffer();
	 sb.append("  select count(1) "
				+" from t_risk_survey_order a "
				+" LEFT JOIN tbl_mcht_inf b ON b.MCHT_CD = a.MERCHANT_NO "
				+" LEFT JOIN tbl_term_inf c ON c.Mcht_CD = a.MERCHANT_NO  "
				+" LEFT JOIN apstfr.tbl_tfr_his_trn_log t ON t.mchnt_cd = a.merchant_no "
				+" where 1=?  ");
	 
		List<Object> params = new ArrayList<Object>();
		params.add("1");
		//根据调单类型来确定原因码
		String type="";
		if(!"".equals(searchCondition.getOrderType())&&searchCondition.getOrderType()!=null){
			//查询
			if(OrderType.FIRST_QUERY.getCode().equals(searchCondition.getOrderType())){
				type=" And A.FIRST_QUERY =? " ;
			}//二次查询 
			else if(OrderType.SECOND_QUERY.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.SECOND_QUERY =? ";
			}//调单
			else if(OrderType.FIRST_SURVEY.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.FIRST_SURVEY =? ";
			}//二次调单
			else if(OrderType.SECOND_SURVEY.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.SECOND_SURVEY =? ";
			}//贷记调整
			else if(OrderType.LOAN_ADJUST.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.LOAN_ADJUST =? ";
			}//请款
			else if(OrderType.FIRST_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.FIRST_WITHDRAW_CASH =? ";
			}//退单
			else if(OrderType.FIRST_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.FIRST_CHARGEBACK =? ";
			}//再请款
			else if(OrderType.SECOND_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.SECOND_WITHDRAW_CASH =? ";
			}//二次退单
			else if(OrderType.SECOND_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.SECOND_CHARGEBACK =? ";
			}
			//例外协议
			else if(OrderType.EXCEPTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.EXCEPTION_NEGOTIATE =? ";
			}//例外长款
			else if(OrderType.EXCEPTION_LONG_MONEY.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.EXCEPTION_LONG_MONEY =? ";
			}//托收请款
			else if(OrderType.COLLECTION_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.COLLECTION_WITHDRAW_CASH =? ";
			}//托收协议
			else if(OrderType.COLLECTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
				type=" and  A.COLLECTION_NEGOTIATE =? ";
			}
			
			
		}
		//商户号
		 if (!"".equals(searchCondition.getMchtCd())&&searchCondition.getMchtCd()!=null){
			sb.append(" and  A.MERCHANT_NO =? ");
			params.add(searchCondition.getMchtCd());
		}
		 
		//账号
		 if (!"".equals(searchCondition.getAccountNo())&&searchCondition.getAccountNo()!=null){
			sb.append(" and  A.account_no =? ");
			params.add(searchCondition.getAccountNo());
		}
		//日期范围
		 if (!"".equals(searchCondition.getMinDate())&&searchCondition.getMinDate()!=null
			 &&!"".equals(searchCondition.getMaxDate())&&searchCondition.getMaxDate()!=null){
			sb.append(" and  A.TRANS_DATE >=?  and A.TRANS_DATE<=? ");
			params.add(searchCondition.getMinDate());
			params.add(searchCondition.getMaxDate());
		}//原因码
		 if (!"".equals(searchCondition.getReasonCd())&&searchCondition.getReasonCd()!=null){
			sb.append(type);
			params.add(searchCondition.getReasonCd());
		}
		
		logger.info("整改商户数量查询sql："+sb.toString());
		int rowCount = 0;
		try {
			if(params.size()>0){
			rowCount = pageDao.countByParams(sb.toString(),params);
			}else{
				rowCount =sqlBaseDao.executeBySql(sb.toString());
			}
				
			logger.info("整改商户数量查询sql结果："+rowCount);
		} catch (Exception e) {
			logger.info("整改商户数量查询异常"+e);
		}
		return rowCount;
	}

	@Override
	public List<ErrorCountBean> queryOrderList(
			OrderProcessSearchCondition searchCondition, int calcuStart,
			int pageMaxSize) throws ServiceException {
		String date = ""; 
		StringBuffer  sb = new StringBuffer();
		if(!"".equals(searchCondition.getOrderType())&&searchCondition.getOrderType()!=null){
			//如果是查询，则查询日期为
			if(OrderType.FIRST_QUERY.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.FIRST_QUERY_DATE ,A.FIRST_QUERY ";
			}//如果是二次查询 ，则二次查询日期为
			else if(OrderType.SECOND_QUERY.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.SECOND_QUERY_DATE , A.SECOND_QUERY  ";
			}//如果是调单 ，则调单日期为
			else if(OrderType.FIRST_SURVEY.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.FIRST_SURVEY_DATE  , A.FIRST_SURVEY ";
			}//如果是二次调单 ，则二次调单日期为
			else if(OrderType.SECOND_SURVEY.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.SECOND_SURVEY_DATE , A.SECOND_SURVEY  ";
			}//如果是贷记调整 ，则贷记调整日期为
			else if(OrderType.LOAN_ADJUST.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.LOAN_ADJUST_DATE  , A.LOAN_ADJUST ";
			}//如果是请款 ，则请款日期为
			else if(OrderType.FIRST_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.FIRST_WITHDRAW_CASH_DATE, A.FIRST_WITHDRAW_CASH  ";
			}//如果是退单 ，则退单日期为
			else if(OrderType.FIRST_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.FIRST_CHARGEBACK_DATE  , A.FIRST_CHARGEBACK  ";
			}//如果是再请款，则再请款日期为
			else if(OrderType.SECOND_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.SECOND_WITHDRAW_CASH_DATE , A.SECOND_WITHDRAW_CASH  ";
			}//如果是二次退单，则二次退单日期为
			else if(OrderType.SECOND_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.SECOND_CHARGEBACK_DATE , A.SECOND_CHARGEBACK  ";
			}
			//如果是例外协商，则例外协商日期为
			else if(OrderType.EXCEPTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.EXCEPTION_NEGOTIATE_DATE  ";
			}//如果是例外长款，则例外长款日期为
			else if(OrderType.EXCEPTION_LONG_MONEY.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.EXCEPTION_LONG_MONEY_DATE  ";
			}//如果是托收请款，则托收请款日期为
			else if(OrderType.COLLECTION_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.COLLECTION_WITHDRAW_CASH_DATE  ";
			}//如果是托收协商，则托收协商日期为
			else if(OrderType.COLLECTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
				date  = " , A.COLLECTION_NEGOTIATE_DATE  ";
			}
			
		}
		
			// TODO Auto-generated method stub
		sb.append(" SELECT  '' 调单日期,''调单类型, ''原因码, " 
					+" (SELECT op.real_name FROM t_operators op WHERE ID = (SELECT e.COMPANYID   FROM t_operators e WHERE e.id = b.ext1)) com_name, "
					+"  a.MERCHANT_NO，t.trans_seq_conv,a.ACCOUNT_NO,  t.card_class， t.pos_entry_md_cd, "
					+" (SELECT op.real_name FROM t_operators op WHERE ID = (SELECT e.ONEAGENTID FROM t_operators e  WHERE e.id = b.ext1)) one_name,"
					+" (SELECT oo.real_name FROM t_operators oo WHERE oo.id = b.ext1) sAgent_name, b.name,"
					+"  a.TRANS_DATE, t.trans_mt, t.trans_at, t.resp_cd, b.REG_ADDR, b.CONTACT_NAME, b.CONTACT_PHONENO,  t.retri_ref_no,"
					+"  a.SECOND_WITHDRAW_CASH_DATE, b.PROV_CD, b.CITY_CD, b.APPL_DATE, c.TERM_ID, t.ma_trans_cd, t.PRI_ACCT_NO, "
					+" (SELECT INS_ID_NM FROM apstfr.tbl_bank_bin_inf d WHERE d.card_bin = t.card_bin) INS_ID_NM, b.UC_BC_CD_32 , "
					+"  CASE '1000' WHEN (SELECT DISTINCT PROD_CD FROM TBL_MCHT_BIZ_DEAL y WHERE y.MCHT_CD = a.MERCHANT_NO AND y.PROD_CD = '1000') THEN 'T1' ELSE '0' END  T1_type, "
				    +"  CASE '1171' WHEN (SELECT DISTINCT PROD_CD FROM TBL_MCHT_BIZ_DEAL y WHERE y.MCHT_CD = a.MERCHANT_NO AND y.PROD_CD = '1171') THEN 'T0' ELSE '0' END  T0_type, "
				    +"  a.SYSTEM_NO ");
				    if(!"".equals(searchCondition.getOrderType())||searchCondition.getOrderType()!=null){
						sb.append(date);
					}
					sb.append("  from t_risk_survey_order a "
					+"  LEFT JOIN tbl_mcht_inf b ON b.MCHT_CD = a.MERCHANT_NO "
					+"  LEFT JOIN tbl_term_inf c ON c.Mcht_CD = a.MERCHANT_NO "
					+"  LEFT JOIN apstfr.tbl_tfr_his_trn_log t ON t.mchnt_cd = a.merchant_no and  a.account_no=t.pri_acct_no  and a.trans_date=t.trans_dt  and  t.trans_seq_conv=a.system_no "
	                +"  where 1=?  ");
			List<Object> params = new ArrayList<Object>();
			
			params.add("1");
			//根据调单类型来确定原因码
			String type="";
			if(!"".equals(searchCondition.getOrderType())&&searchCondition.getOrderType()!=null){
				//查询
				if(OrderType.FIRST_QUERY.getCode().equals(searchCondition.getOrderType())){
					type=" And A.FIRST_QUERY  " ;
				}//二次查询 
				else if(OrderType.SECOND_QUERY.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.SECOND_QUERY  ";
				}//调单
				else if(OrderType.FIRST_SURVEY.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.FIRST_SURVEY ";
				}//二次调单
				else if(OrderType.SECOND_SURVEY.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.SECOND_SURVEY  ";
				}//贷记调整
				else if(OrderType.LOAN_ADJUST.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.LOAN_ADJUST  ";
				}//请款
				else if(OrderType.FIRST_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.FIRST_WITHDRAW_CASH  ";
				}//退单
				else if(OrderType.FIRST_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.FIRST_CHARGEBACK  ";
				}//再请款
				else if(OrderType.SECOND_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.SECOND_WITHDRAW_CASH  ";
				}//二次退单
				else if(OrderType.SECOND_CHARGEBACK.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.SECOND_CHARGEBACK  ";
				}
				//例外协议
				else if(OrderType.EXCEPTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.EXCEPTION_NEGOTIATE  ";
				}//例外长款
				else if(OrderType.EXCEPTION_LONG_MONEY.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.EXCEPTION_LONG_MONEY  ";
				}//托收请款
				else if(OrderType.COLLECTION_WITHDRAW_CASH.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.COLLECTION_WITHDRAW_CASH  ";
				}//托收协议
				else if(OrderType.COLLECTION_NEGOTIATE.getCode().equals(searchCondition.getOrderType())){
					type=" and  A.COLLECTION_NEGOTIATE  ";
				}
				
				
			}
			//商户号
			 if (!"".equals(searchCondition.getMchtCd())&&searchCondition.getMchtCd()!=null){
				sb.append(" and  A.MERCHANT_NO =? ");
				params.add(searchCondition.getMchtCd());
			}
			
			//账号
			 if (!"".equals(searchCondition.getAccountNo())&&searchCondition.getAccountNo()!=null){
				sb.append(" and  A.account_no =? ");
				params.add(searchCondition.getAccountNo());
			}
			//日期范围
			 if (!"".equals(searchCondition.getMinDate())&&searchCondition.getMinDate()!=null
				 &&!"".equals(searchCondition.getMaxDate())&&searchCondition.getMaxDate()!=null){
				sb.append(" and  A.TRANS_DATE >=?  and A.TRANS_DATE<=? ");
				params.add(searchCondition.getMinDate());
				params.add(searchCondition.getMaxDate());
			}//原因码      调单类型中的原因码=原因码
			 if (!"".equals(searchCondition.getReasonCd())&&searchCondition.getReasonCd()!=null){
				sb.append(type+ "  = ? ");
				params.add(searchCondition.getReasonCd());
			}//调单类型 
			 if (!"".equals(searchCondition.getOrderType())&&searchCondition.getOrderType()!=null){
				sb.append(type+ "  is not  null ");
				
			}

			 
			 
			logger.info("查询sql:"+sb);
			List<Object> searchRsList=new ArrayList<Object>();
			List<ErrorCountBean> ccList= new ArrayList<ErrorCountBean>();
			try {
				if(params.size()>0){
					searchRsList = pageDao.findAllByParams(sb.toString(), params, calcuStart,  pageMaxSize);
				}else{
					searchRsList = sqlBaseDao.queryAll(sb.toString());
				}
				logger.info("查询到记录："+searchRsList.size()+"条");
				ccList = dealTheListSpecially(ccList,searchRsList, searchCondition);
			} catch (Exception e) {
				logger.info("查询差错统计数据数据异常"+e);
			}
			return ccList;
		}


		private List<ErrorCountBean> dealTheListSpecially(List<ErrorCountBean> ecList, List<Object> searchRsList,OrderProcessSearchCondition searchCondition) throws ServiceException{
			 Map<String,String> respondeMap = ConfigProperties.getSysDB1("RESP_CD",false);
			if(searchRsList != null && searchRsList.size()>0){
				Iterator it = searchRsList.iterator();
				while(it.hasNext()){
					Object[] obj= (Object[])it.next();
					ErrorCountBean  ecb=new ErrorCountBean(); 
					if(!"".equals(searchCondition.getOrderType())&&searchCondition.getOrderType()!=null){
						ecb.setDate(Constance.Null2EmptyTrim(obj[32]));
					}
					
					ecb.setOrderType(Constant.REASON_MAP.get(searchCondition.getOrderType()));
					ecb.setReasonCode(Constance.Null2EmptyTrim(obj[33]));
					ecb.setCompanyid(Constance.Null2EmptyTrim(obj[3]));
					ecb.setMerchantNo(Constance.Null2EmptyTrim(obj[4]));
					ecb.setTransSeqConv(Constance.Null2EmptyTrim(obj[5]));
					ecb.setAccountNo(Constance.Null2EmptyTrim(obj[6]));
					ecb.setCardClass( Constant.CARD_CLASS_MAP.get(Constance.Null2EmptyTrim(obj[7])));
					
					String cardClass = Constance.Null2EmptyTrim(obj[7]);
					String posEntrymd = Constance.Null2EmptyTrim(obj[8]);
					if(posEntrymd.length()<3){
						ecb.setPosEntryMdCdName("未知");
					}else if("02".equals(posEntrymd.substring(0, 2))){
						ecb.setPosEntryMdCdName("磁条卡");
					}else if("05".equals(posEntrymd.substring(0, 2))){
						ecb.setPosEntryMdCdName("芯片插卡");
					}else if("07".equals(posEntrymd.substring(0, 2))){
						if("0".equals(cardClass.substring(0, 1))){
							ecb.setPosEntryMdCdName("芯片非接");
						}
						if("1".equals(cardClass.substring(0, 1))){
							ecb.setPosEntryMdCdName("芯片云闪付");
						}
					}else if("98".equals(posEntrymd.substring(0, 2))){
						if("0".equals(cardClass.substring(0, 1))){
							ecb.setPosEntryMdCdName("芯片非接");
						}
						if("1".equals(cardClass.substring(0, 1))){
							ecb.setPosEntryMdCdName("芯片云闪付");//判断卡片性质
						}
					}
					
					ecb.setOnegentid(Constance.Null2EmptyTrim(obj[9]));
					ecb.setsAgentName(Constance.Null2EmptyTrim(obj[10]));
					ecb.setName(Constance.Null2EmptyTrim(obj[11]));
					ecb.setTransDate(Constance.Null2EmptyTrim(obj[12]));
					ecb.setTransMt(Constance.Null2EmptyTrim(obj[13]));
					ecb.setTransAt(Constance.Null2EmptyTrim(obj[14]));
//					respondeMap.get(key)
					ecb.setRespCd(respondeMap.get(Constance.Null2EmptyTrim(obj[15])));
					ecb.setRegAddr(Constance.Null2EmptyTrim(obj[16]));
					ecb.setContactName(Constance.Null2EmptyTrim(obj[17]));
					ecb.setContactPhoneno(Constance.Null2EmptyTrim(obj[18]));
					ecb.setRetriRefNo(Constance.Null2EmptyTrim(obj[19]));
					ecb.setSecondWithdrawCashDate(Constance.Null2EmptyTrim(obj[20]));
					Map<String,String> areaMap = ConfigProperties.getGBProviceProperties();
					ecb.setProvCd(areaMap.get(Constance.Null2EmptyTrim(obj[21])));//省
					Map<String, String> areamap = 
							ConfigProperties.getGBCityProperties(Constance.Null2EmptyTrim(obj[21]));
	                
					ecb.setCityCd(areamap.get(Constance.Null2EmptyTrim(obj[22])));//市
					ecb.setRecCrtTs(Constance.Null2EmptyTrim(obj[23]));
					ecb.setTermId(Constance.Null2EmptyTrim(obj[24]));
					//四要素
					
					String acctNo=Constance.Null2EmptyTrim(obj[25]);
					int count=0;
					count = estrnStasticsService.validationFourElements(acctNo);//查询卡号是否进行了四要素验证
					if(count>0){
						ecb.setFourElements("是");
					}else{
						ecb.setFourElements("否");
					}
					ecb.setInsIdNm(Constance.Null2EmptyTrim(obj[27]));//发卡行
					
					//32域
					String ss=Constance.Null2EmptyTrim(obj[28]);
					if(ss!=null&&ss.length()>4){
					String 	end_four=ss.substring(ss.length()-4);
					ecb.setUcBcCd32(end_four);
					}else 
					ecb.setUcBcCd32(ss);
					
					//交易类型T0/T1
					StringBuffer sb=new StringBuffer();
					 if(!Constance.Null2EmptyTrim(obj[29]).equals("0")){
	                     sb.append(Constance.Null2EmptyTrim(obj[29]));
	                 }
	                 if(!Constance.Null2EmptyTrim(obj[30]).equals("0")){
	                     sb.append(Constance.Null2EmptyTrim(obj[30]));
	                 }
	                 if(!Constance.Null2EmptyTrim(obj[29]).equals("0") && !Constance.Null2EmptyTrim(obj[30]).equals("0") ){
	                     sb.setLength(0);
	                     sb.append(Constance.Null2EmptyTrim(obj[29])).append("/"+Constance.Null2EmptyTrim(obj[30]));
	                 }
	                 ecb.setMaTransCd(sb.toString());
					
	                 ecb.setSystemNo(Constance.Null2EmptyTrim(obj[31]));
					
					ecList.add(ecb);
				}
			}
			return ecList;
			
		}

}
